<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>Title</title>
</head>
<body>

<div id="app">
    <h1>the goods page</h1>
    <table>
        <thead>
        <tr>
            <td>id</td>
            <td>name</td>
            <td>remark</td>
            <td>createdTime</td>
            <td>delete</td>
        </tr>
        </thead>
        <tbody id="tbodyId">
        <tr v-for="good in goods">
            <td>{{good.id}}</td>
            <td>{{good.name}}</td>
            <td>{{good.remark}}</td>
            <td>{{good.createdTime}}</td>
            <td><a @click="doDeleteById(good.id)">删除</a></td>
        </tr>
        </tbody>
    </table>
</div>


</body>
<script src="js/axios.min.js"></script>
<script src="js/vue.js"></script>
<script>
    var config = {
        el: "#app",
        data: {goods: []},
        methods: {
            doDeleteById:function (id) {
                let url = `/doDeleteById/${id}`;
                axios.get(url)
                .then(function (result) {
                    alert(result.data.msg);
                    this.vue.doFindgoods();
                }).catch(function (e ) {
                    console.log(e);
                })
            },
            doFindgoods:function () {
                let url = "/doFindGoods"
                axios.get(url)
                    .then(function (result) {
                        this.vue.goods = result.data.data;
                        alert(result.data.msg);
                        console.log(this.vue.goods);
                    })
                    .catch(function (e) {
                        console.log(e);
                    })
            }
        },
        mounted: function () {
            this.doFindgoods();
        }
    };
    var vue = new Vue(config);

</script>
</html>